package dfbz.线程锁;

public class RunnableImpl implements Runnable {
    private static Integer ticket = 100;//票
    private static Object obj = new Object();

    @Override
    public void run() {
        while (true) {
            synchronized (obj) {
                if (ticket > 0) {
                    System.out.println("当前窗口" + Thread.currentThread().getName() + "正在卖第" + ticket + "张票");
                    ticket--;
                }
            }
        }
    }
}
